package com.flower.domain.service.impl;

import cn.dev33.satoken.secure.SaSecureUtil;
import com.flower.auth.common.enums.AuthUserStatusEnum;
import com.flower.auth.common.enums.IsDeletedFlagEnum;
import com.flower.auth.infra.basic.entity.AuthRole;
import com.flower.auth.infra.basic.entity.AuthUser;
import com.flower.auth.infra.basic.service.AuthRoleService;
import com.flower.auth.infra.basic.service.AuthUserService;
import com.flower.domain.convert.AuthRoleBOConverter;
import com.flower.domain.convert.AuthUserBOConverter;
import com.flower.domain.entity.AuthRoleBO;
import com.flower.domain.entity.AuthUserBO;
import com.flower.domain.service.AuthRoleDomainService;
import com.flower.domain.service.AuthUserDomainService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-07-16 21:24
 */
@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {

    @Resource
    private AuthRoleService  service;





    @Override
    public Boolean register(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToUser(authRoleBO);

        authRole.setIsDelete(IsDeletedFlagEnum.UN_DELETED.getCode());

        Integer result = service.insert(authRole);

        return result > 0;

    }

    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToUser(authRoleBO);
        Integer result = service.update(authRole);

        return result > 0;
    }

    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToUser(authRoleBO);
        authRole.setIsDelete(IsDeletedFlagEnum.DELETE.getCode());
        Integer result = service.update(authRole);

        return result > 0;
    }
}
